 
***Note: replicators should set directory to open data 
*cd ""

*Also note data are in .sav format, need to be put in stata

********** FIGURE 2i: Gender Attitudes, World **********

*Based on Pew Research data, see appendix. Original dataset:  World value survey.  

clear all
use WVS.dta
 
 label var D "Discrimination"
 label var PD "Perceptions of discrimination"

 set scheme s1mono
 
 rename country Country
 
decode Country, gen(country) 

gen Europe=0
replace  Europe=1 if country=="Ukraine" |   country=="Switzerland" |  country=="Sweden" |  country=="Spain" |  country=="Slovenia" |  country=="Serbia" |  country=="Romania" |  country=="Poland" |  country=="Norway" |  country=="Moldova" |  country=="Italy" |  country=="Hungary" |  country=="Germany" | country=="Finland" |  country=="Cyprus" |  country=="Bulgaria" |  country=="Andorra"  
	
 
gen Americas=0
replace  Americas=1 if country=="Uruguay" |   country=="Trinidad and Tobago" |  country=="Peru" |  country=="Mexico" |  country=="Chile" |  country=="Brazil" |  country=="Argentina"  |  country=="Canada"  
	
gen Africa=0
replace  Africa=1 if country=="Zambia" |   country=="Burkina Faso" |  country=="Egypt" |  country=="South Africa" |  country=="Rwanda" |  country=="Morocco" |  country=="Mali" |  country=="Ethiopia"  

gen Asia=0
replace  Asia=1 if country=="Turkey" |   country=="Thailand" |  country=="Vietnam" |  country=="" |  country=="" |  country=="Malaysia" |  country=="South Korea" |  country=="Jordan" |  country=="Japan" |  country=="Indonesia" |  country=="India" |  country=="Georgia" |  country=="Taiwan" |  country=="China"    

gen Oceania=0
replace  Oceania=1 if country=="Australia"  


gen Area=.
replace Area=1 if Africa==1
replace Area=2 if Americas==1
replace Area=3 if Asia==1
replace Area=4 if Europe==1
replace Area=5 if Oceania==1


label variable Area "Continent"
la def aria  1 "Africa" 2 "Americas"  3 "Asia" 4 "Europe" 5 "Oceania", modify
la val Area aria

   grstyle init
 grstyle set legend 2,  nobox
 grstyle set size 8pt: tick_label key_label
 grstyle set size 12pt: heading
 grstyle set size 10pt: subheading axis_title 
 grstyle set graphsize 13cm 11.5cm
 

reg    PD D
ereturn list
loc N6= e(N)
local b= round(_b[D],.001)
local t = _b[D]/_se[D]
local p =round(2*ttail(e(df_r),abs(`t')),.001)


  graph twoway    (lfitci PD  D,   lcol(black)  lwidth(medthick) ciplot(rline) blpattern(dash) acolor(black%65) )     (scatter PD  D if Area==1,       mcolor(black)   msymbol(d))   (scatter PD  D if Area==2,   mcolor(black)    msymbol(S)) (scatter PD  D if Area==3,   mcolor(black)      msymbol(o)) (scatter PD  D if Area==4,   mcolor(black)    msymbol(T)) (scatter PD  D if Area==5,   mcolor(black)    msymbol(X)), name(a, replace)    legend(position(12) rows(1)  order(3 "Africa" 4 "Americas" 5 "Asia" 6 "Europe" 7 "Oceania") span) ytitle("Perceptions of discrimination")    xtitle("Discriminatory attitudes") note("Author's computation based on the World Value Survey." "Plot country-round pairwise correlation. {&rho} = `b' | {it:p-value} = `p' | {it:N} = `N6'." ,size(vsmall) span) subtitle("{bf: Gender attitudes in the World}") 
  graph export "Graph/Figure2i.tif", replace 
  graph save "Graph/Figure2i", replace
 